﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TKToXML.Models
{
    public class HoaDon : BaseChungTu
    {
        //public virtual int LoaiChungTu { get; set; }
        //public virtual int NamChungTu { get; set; }
        //public virtual int SoChungTu { get; set; }
        public virtual DateTime NgayChungTu { get; set; }
        //public virtual DateTime NgayKhaiBao { get; set; }
        //public virtual string MaHQTiepNhan { get; set; }
        //public virtual int NamTiepNhan { get; set; }
        //public virtual int SoTiepNhan { get; set; }
        //public virtual DateTime NgayTiepNhan { get; set; }
        //public virtual int SoDangKy { get; set; }
        //public virtual DateTime NgayDangKy { get; set; }
        
        public virtual int NamTK { get; set; }
        public virtual int SoTK { get; set; }
        public virtual string SoHoaDon { get; set; }
        public virtual DateTime NgayHoaDon { get; set; }        
        public virtual string MaDV { get; set; }
        public virtual string TenDV { get; set; }
        public virtual string MaDVBanHang { get; set; }
        public virtual string TenDVBanHang { get; set; }
        public virtual string MaDVMuaHang { get; set; }
        public virtual string TenDVMuaHang { get; set; }        
        public virtual string MaPTTT { get; set; }
        public virtual string MaDKGH { get; set; }        
        public virtual string MaNguyenTe { get; set; }
        public virtual decimal TriGiaNguyenTe { get; set; }        
        public virtual DateTime NgayNhapMay { get; set; }
        public virtual string NguoiNhapMay { get; set; }

        public virtual IList<HoaDonChiTiet> HoaDonChiTiets { get; set; }
        
        public virtual string ToXML()
        { 
            string result = "";
            result += "<CommercialInvoices>";
                result += "<CommercialInvoice>";
                    result += "<reference>" + SoHoaDon + "</reference>";
                    result += "<issue>" + NgayHoaDon.ToString("yyyy-MM-dd") + "</issue>";
                    result += "<Seller>";
                        result += "<name>" + TenDVBanHang + "</name>";
                        result += "<identity>" + MaDVBanHang + "</identity>";
                    result += "</Seller>";
                    result += "<Buyer>";
                        result += "<name>" + TenDVMuaHang + "</name>";
                        result += "<identity>" + MaDVMuaHang + "</identity>";
                    result += "</Buyer>";
                    result += "<Payment>";
                        result += "<method>" + MaPTTT + "</method>";
                    result += "</Payment>";
                    result += "<CurrencyExchange>";
                        result += "<currencyType>" + MaNguyenTe + "</currencyType>";
                    result += "</CurrencyExchange>";
                    result += "<TradeTerm>";
                        result += "<condition>" + MaNguyenTe + "</condition>";
                    result += "</TradeTerm>";
                result += "</CommercialInvoice>";
            result += "</CommercialInvoices>";
            return result;
        }
    }
}
